package Framework;

import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;

public class btn_Toggle extends btn_Ancestor implements ActionListener {

	boolean ib_Toggled = false;
	ImageIcon img_Background_Down_Hover;
	String is_ToggledText;
	String is_startingText;
	
	public void setToggledText(String s){
		is_ToggledText = s;
	}
	public void setimg_Background_Down_Hover( String as_image ) {
		img_Background_Down_Hover = nv_ImageLoader.loadImage(as_image);
	}
	
	public void actionPerformed(ActionEvent arg0) {
		
		if (ib_Toggled == false) {
			Toggle();
			ib_Toggled = true;
			this.setText(is_ToggledText);
		} else {
			Toggle(); 
			ib_Toggled = false;
			this.setText(is_startingText);
		}
		this.getRootPane().repaint();
	}
	
	public void Toggle(){
		
		ImageIcon tempSwitch = img_Background_Down_Hover;

		img_Background_Down_Hover = img_Background_Hover;
		img_Background_Hover = tempSwitch;
		
		tempSwitch = img_Background_Standard;
		img_Background_Standard = img_Background_Down;
		img_Background_Down = tempSwitch;
		
				
	}
	public btn_Toggle(String text) {
		super(text);
		setimg_Background_Down_Hover("img/btn.png");
		this.addActionListener(this);
		this.is_startingText = text;
		this.setToggledText(text);
	}
	public btn_Toggle(String text, String toggledText) {
		this(text);
		this.setToggledText(toggledText);
	}
}
